<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面向对象的封装与抽象</title>
</head>
<body>
    <script>
        function User(name,age){
            this.name = name;
            this.age = age;
            this.show = function(){
                console.log(this.name + this.info());
            };
            this.info = function(){
                return `我叫${this.name}，今年${this.age}岁`
            }
        }

        let xiasnn = new User('xiasnn',18);
        // 这边还能修改name的值，说明未进行抽象
        xiasnn.name = "后盾人";
        // 这边还能修改info方法的内容，说明未进行抽象
        xiasnn.info = function(){
            return '哈哈哈哈';
        }
        xiasnn.show();



        function User2(name,age){
            let data = {name,age};
            this.show = function(){
                console.log(data.name + info());
            };
            let info = function(){
                return `我叫${data.name}，今年${data.age}岁`
            }
        }

        let lisi = new User2('李四',22);
        // 这边不能修改name的值，说明进行了抽象
        lisi.name = "333";
        // 这边不能修改info方法的内容，说明进行了抽象
        lisi.info = function(){
            return '哈哈哈哈';
        }
        lisi.show();
    </script>
</body>
</html>